/*******************************************************************************
 * Copyright (c) 2010, 2030 www.itlaobing.cn
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package cn.itlaobing.web.servlet;/**
 * Created by asus-pc on 2017/11/14 0014.
 */

import cn.itlaobing.dao.BaseDao;
import cn.itlaobing.dao.GoodsDao;
import cn.itlaobing.entity.GoodsDTO;
import cn.itlaobing.entity.Itlb_focuss;
import cn.itlaobing.entity.NewGoodsDTO;
import cn.itlaobing.web.annotation.RequestMapping;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;
import java.util.List;

/**
 * ClassName: GoodsServlet <br/>
 * Function: TODO 功能描述 <br/>
 * date: 2017/11/14 0014 14:42 <br/>
 *
 * @author 卖姑娘的小柴火
 * @since JDK 1.8
 */
@WebServlet("/goods/*")
public class GoodsServlet extends BaseServlet {

    /**
     * 页面展示
     * @param req
     * @param resp
     * @throws ServletException
     * @throws IOException
     */
    @RequestMapping("/show")
    public void show(HttpServletRequest req, HttpServletResponse resp) throws ServletException,IOException {
        req.setCharacterEncoding("utf-8");
        GoodsDao gd = new GoodsDao();
        List<GoodsDTO> list1= null;
        List<NewGoodsDTO> list2=null;
        List<Itlb_focuss> list3=null;


        try {
            list1 = gd.checkgoods();
            list2=gd.checkByNewGoods();
            list3=gd.focuss();
                req.getSession().setAttribute("goods", list1);
                req.getSession().setAttribute("newgoods",list2);
                req.getSession().setAttribute("focuss",list3);
                req.getRequestDispatcher("/WEB-INF/views/index.jsp").forward(req, resp);
//            System.out.println(list1);
//            System.out.println(list2);
            return;
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

//    @RequestMapping("/shownew")
//    public void shonew(HttpServletRequest req, HttpServletResponse resp) throws ServletException,IOException {
//        req.setCharacterEncoding("utf-8");
//        GoodsDao gd = new GoodsDao();
//        List<GoodsDTO> list = null;
//        try {
//            list = gd.checkByNewGoods();
//            req.setAttribute("new", list);
//            req.getRequestDispatcher("/WEB-INF/views/index.jsp").forward(req, resp);
//        } catch (SQLException e) {
//            e.printStackTrace();
//        }
//    }

}
